package com.technoorbit.vbreakup;


import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;


public class SessionMaster {
	static final String USER_INFO = "UserInfo";
	static SharedPreferences prefs;
	static Editor editor;
	public static void StoreUserInfo(String userName,String Password, Context context)
	{
		prefs = context.getSharedPreferences(USER_INFO, 0);
		editor = prefs.edit();
		editor.putBoolean("isLoggedIn", true);
		 
		editor.putString("userName", userName);
		editor.putString("Password", Password);
		editor.commit();
	}
	
	
	public static String getUserName(Context context)
	{
		   SharedPreferences settings = context.getSharedPreferences(USER_INFO, 0);
	       String userName = settings.getString("userName","");
	       return userName;
	}
	
	public static String getPassword(Context context)
	{
		   SharedPreferences settings = context.getSharedPreferences(USER_INFO, 0);
	       String password = settings.getString("Password","");
	       return password;
	}

public static boolean verifyLogin(String userName,String Password, Context context){
	if	(userName.equals(getUserName(context)) && Password.equals(getPassword(context)))
	{
		return	 true;
	}else{
		return false;
	}
}

// Get Login State
public static boolean isLoggedIn(Context context){
	prefs = context.getSharedPreferences(USER_INFO, 0);
    return prefs.getBoolean("isLoggedIn", false);
}

public static void ClearUserSession(Context context){
	prefs = context.getSharedPreferences(USER_INFO, 0);
	editor = prefs.edit();
	editor.putBoolean("isLoggedIn", false);
	editor.putString("userName", "");
	editor.putString("Password", "");
	editor.commit();
}

}
